﻿using System;
using System.Data;
using BizElements.Core.ProviderComponents;

namespace BizElements.Core.DB2
{
    /// <summary>Builds <see cref="DB2ConnectionProvider"/> objects.</summary>
    sealed class DB2ConnectionProviderBuilder : IConnectionProviderBuilder
    {
        /// <summary>Creates a new connection provider, ie. connection-transaction context.</summary>
        /// <param name="dbms">DBMS type to which this provider connects to. Only values compatibile with DB2 databases are allowed.</param>
        /// <param name="connectionString">Connection string.</param>
        /// <returns>Connection provider.</returns>
        public IConnectionProvider BuildConnectionProvider(DbmsType dbms, string connectionString)
        {
            return new DB2ConnectionProvider(dbms, connectionString);
        }

        /// <summary>Creates a new connection provider, ie. connection-transaction context.</summary>
        /// <param name="dbms">DBMS type to which this provider connects to. Only values compatibile with DB2 databases are allowed.</param>
        /// <param name="connectionString">Connection string.</param>
        /// <param name="defaultIsolationLevel">Isolation level for transactions started by the parameterless <see cref="BizElements.Core.IConnectionProvider.BeginTransaction()"/> method overload.</param>
        /// <returns>Connection provider.</returns>
        public IConnectionProvider BuildConnectionProvider(DbmsType dbms, string connectionString, IsolationLevel defaultIsolationLevel)
        {
            return new DB2ConnectionProvider(dbms, connectionString, defaultIsolationLevel);
        }
    }
}
